﻿/*-----------------------------------------------
// File: GuideOptionTarget.cs
// Description: 
// Author: Shaobing	492057342@qq.com
-----------------------------------------------*/
using UnityEngine;
using System.Collections;

namespace Battle.View
{
    public class GuideOptionTarget : MonoBehaviour
    {
        public enum OptionalTargetType {
            Left_Click,
            Right_Click,
            TopForwardDrag,
        }

        public enum OptionalTargetEffectColor
        {
            Blue,
            Yellow,
        }

        public OptionalTargetEffectColor curColor = OptionalTargetEffectColor.Blue;
        public Color GetColor(OptionalTargetEffectColor c)
        {
            if (c == OptionalTargetEffectColor.Blue)
            {
                return new Color(0.02f, 0.92f, 1f, 1f);
            }
            else if (c == OptionalTargetEffectColor.Yellow)
            {
                return new Color(1f, 1f, 0f, 1f);
            }
            else
            {
                return new Color(0.02f, 0.92f, 1f, 1f);
            }
        }

        public UITweener right_clickTweener;
        public UITweener left_clickTweener;
        public UITweener topForwardTweener;
        public GameObject clickEffect;

        public void Show(OptionalTargetType type, Vector3 pos, OptionalTargetEffectColor color = OptionalTargetEffectColor.Blue) {
            gameObject.SetActive(true);
            transform.localPosition = pos;
            if (type == OptionalTargetType.Right_Click)
            {
                right_clickTweener.gameObject.SetActive(true);
                right_clickTweener.enabled = true;
                topForwardTweener.enabled = false;
                right_clickTweener.ResetToBeginning();
                right_clickTweener.PlayForward();
                left_clickTweener.gameObject.SetActive(false);
                clickEffect.SetActive(true);
            }
            else if (type == OptionalTargetType.Left_Click) {
                left_clickTweener.gameObject.SetActive(true);
                left_clickTweener.enabled = true;
                left_clickTweener.ResetToBeginning();
                left_clickTweener.PlayForward();
                right_clickTweener.gameObject.SetActive(false);
                clickEffect.SetActive(true);
            }
            else if (type == OptionalTargetType.TopForwardDrag)
            {
                right_clickTweener.gameObject.SetActive(true);
                left_clickTweener.gameObject.SetActive(false);

                right_clickTweener.enabled = false;
                topForwardTweener.enabled = true;
                topForwardTweener.ResetToBeginning();
                topForwardTweener.PlayForward();
                clickEffect.SetActive(false);
            }

            if (curColor != color)
            {
                foreach (var ps in clickEffect.GetComponentsInChildren<ParticleSystem>())
                {
                    ps.startColor = GetColor(color);
                }
                curColor = color;
            }
        }
        public void Hide() {
            gameObject.SetActive(false);
        }
    }

}